package com.ort.ezcalendar.mapa;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import com.ort.ezcalendar.R;
import com.ort.ezcalendar.Sistema;

public class MapaSeleccionarLocActivity extends MapActivity {

	private LocationManager manager;
	String proveedor;
	private MapaSeleccionOverlay overlay;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		manager = (LocationManager) getSystemService(this.LOCATION_SERVICE);
		Criteria criteria = new Criteria();

		try {
			proveedor = manager.getBestProvider(criteria, true);
			setContentView(R.layout.activity_mapa);
			MapView mapView = (MapView) findViewById(R.id.mapview);
			mapView.setBuiltInZoomControls(true);
			List<Overlay> mapOverlays = mapView.getOverlays();
			Drawable drawable = this.getResources().getDrawable(
					R.drawable.marcador_mapa);
//			overlay = new MapaSeleccionOverlay(drawable, this);
//			if (Sistema.getInstance().getLatitud() != null
//					&& Sistema.getInstance().getLongitud() != null) {
//				double latitud = getIntent().getExtras().getDouble("latitud");
//				double longitud = getIntent().getExtras().getDouble("longitud");
//				GeoPoint g = new GeoPoint((int) (latitud * 1E6),
//						(int) (longitud * 1E6));
//				overlay.agregarOverlay(new OverlayItem(g, "Actual",
//						"Lugar actual del evento"));
//			}
//			if (overlay.size() > 0) {
//				mapOverlays.add(overlay);
//			}
			overlay = new MapaSeleccionOverlay(this);
			mapOverlays.add(overlay);

		} catch (Exception ex) {
			Toast toast = Toast.makeText(this, "No es posible mostrar el mapa",
					10000);
			toast.show();
		}
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

}
